using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class RewardPointsHistoryMap : EntityTypeConfiguration<RewardPointsHistory>
    {
        public RewardPointsHistoryMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("RewardPointsHistory");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.CustomerId).HasColumnName("CustomerId");
            this.Property(t => t.Points).HasColumnName("Points");
            this.Property(t => t.PointsBalance).HasColumnName("PointsBalance");
            this.Property(t => t.UsedAmount).HasColumnName("UsedAmount");
            this.Property(t => t.Message).HasColumnName("Message");
            this.Property(t => t.CreatedOnUtc).HasColumnName("CreatedOnUtc");
            this.Property(t => t.UsedWithOrder_Id).HasColumnName("UsedWithOrder_Id");

            // Relationships
            this.HasRequired(t => t.Customer)
                .WithMany(t => t.RewardPointsHistories)
                .HasForeignKey(d => d.CustomerId);
            this.HasOptional(t => t.Order)
                .WithMany(t => t.RewardPointsHistories)
                .HasForeignKey(d => d.UsedWithOrder_Id);

        }
    }
}
